<template>
  <tr>
    <td><input type="checkbox" v-model="checkAll" /></td>
    <td>{{ name }}</td>
    <td>{{ price }}</td>
    <td>
      <button @click="btnSub">-</button>{{ num }}
      <button @click="btnAdd">+</button>
    </td>
    <td>{{ total }}</td>
    <td><button @click="btnDel">删除</button></td>
  </tr>
</template>

<script>
export default {
  data () {
    return {
      total: 0,
      checkAll: this.checked
    }
  },
  props: ['name', 'price', 'num', 'checked'],

  created () {},
  watch: {
    checkAll (newVal) {
      this.$emit('check', [newVal, this.name])
    },
    checked (newval) {
      this.checkAll = newval
    }
  },

  methods: {
    btnSub () {
      this.$emit('BtnSub', this.name)
    },
    btnAdd () {
      this.$emit('BtnAdd', this.name)
    },
    btnDel () {
      this.$emit('BtnDel', this.name)
    }
  }
}
</script>

<style scoped lang="less"></style>
